/**
 * 
 */
package wayic.http;

/**
 * @author Ashesh Nishant
 * Created, Feb 26, 2009 1:35:40 AM
 * 
 * Wraps around 
 * - response body of an HTTP method as String
 * - Htpp header of the content 
 */
public class Content {
    
    protected ContentHeader contentHeader;
    protected String content;
    
    /**
     * @return the contentHeader
     */
    public ContentHeader getContentHeader() {
        return contentHeader;
    }
    
    /**
     * @param contentHeader the contentHeader to set
     */
    public void setContentHeader(ContentHeader contentHeader) {
        this.contentHeader = contentHeader;
    }

    /**
     * @return the content
     */
    public String getContent() {
        return content;
    }

    /**
     * @param content the content to set
     */
    public void setContent(String content) {
        this.content = content;
    }
    
    /**
     * @see java.lang.Object#toString()
     */
    public String toString(){
        return content;
    }
    
    public int getHTTPStatusCode(){
        if(contentHeader != null){
            return contentHeader.getStatusCode();
        }
        return -1;
    }

    /**
     * @see java.lang.Object#hashCode()
     */
    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((contentHeader == null) ? 0 : contentHeader.hashCode());
        return result;
    }

    /**
     * @see java.lang.Object#equals(java.lang.Object)
     */
    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        Content other = (Content) obj;
        if (contentHeader == null) {
            if (other.contentHeader != null)
                return false;
        } else if (!contentHeader.equals(other.contentHeader))
            return false;
        return true;
    }

}
